<template>
  <div>
    <h2>登录</h2>
    <p>请输入用户名：<input type="text" v-model="form.name"></p>
    <p>请输入用账号：<input type="text" v-model="form.username"></p>
    <p>请输入密码：<input type="text" v-model="form.password"></p>
    <p>请输入所属年级：<input type="text" v-model="form.niaji"></p>
    <button @click="fdla">登录</button>
  </div>
</template>

<script>
export default {
  name: "fdl",
  data() {
    return {
      form: {}
    }
  },
  methods: {
    fdla() {
      this.$axios.post('users/PdlAPI/', this.form)
        .then(res => {
          if (res.data.code == 200) {
            alert('ok')
            localStorage.setItem('name',res.data.name)
            localStorage.setItem('banji',res.data.banji)
            localStorage.setItem('userid',res.data.userid)
            this.$router.push({path:'/xpy'})
          } else {
            alert('no')
          }
        })
    }
  }
}
</script>

<style scoped>

</style>
